<template>
  <section class="platform-intro">
    <div class="container">
      <div class="intro-content">
        <h1 class="intro-title">
          广西<span class="text-gradient">人工智能</span> 应用平台
        </h1>
        <p class="intro-description">
          集成最先进的AI模型，提供简单易用的API接口，助力开发者构建智能应用，加速数字化转型
        </p>
        <div class="intro-buttons">
          <button 
            class="btn btn-primary" 
            :class="{ 'btn-active': isStartActive }"
            @click="handleStartClick"
          >
            <i class="fas fa-play-circle"></i>
            <span>开始使用</span>
          </button>
          <button class="btn btn-outline" @click="handleViewDocumentation">
            <i class="fas fa-file-alt"></i>
            <span>查看文档</span>
          </button>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: 'HomeBanner',
  data() {
    return {
      isStartActive: false
    }
  },
  methods: {
    handleStartClick() {
      var self = this;
      self.isStartActive = true;
      
      // 从环境变量获取appName，使用test作为默认值（对应后端配置文件中的Dify应用ID）
      const appName = process.env.VUE_APP_APP_NAME || 'test';
      
      // 跳转到聊天页面，并带上appName参数
      const url = `/agent-function/AIchat?appName=${encodeURIComponent(appName)}`;
      window.location.href = url;
      
      // 可选：添加点击效果持续时间
      setTimeout(function() {
        self.isStartActive = false;
      }, 2000); // 2秒后恢复原状
    },
    handleViewDocumentation() {
      // 跳转到与导航栏文档菜单项相同的页面
      window.location.href = '/user/ai-documentation';
    }
  }
}
</script>

<style scoped>
/* CSS 变量回退 */
.platform-intro {
  --primary: #4361ee;
  --primary-light: #4895ef;
  --primary-hover: #3a56d4;
  --bg-card: #ffffff;
  --text-secondary: #4a4a6a;
  --radius: 8px;
  --radius-xl: 24px;
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s ease;
}

.platform-intro {
  padding: 100px 0 40px;
  text-align: center;
  background: -webkit-linear-gradient(135deg, 
    rgba(37, 99, 235, 0.03) 0%, 
    rgba(59, 130, 246, 0.05) 100%);
  background: linear-gradient(135deg, 
    rgba(37, 99, 235, 0.03) 0%, 
    rgba(59, 130, 246, 0.05) 100%);
  -webkit-transition: var(--transition);
  transition: var(--transition);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.intro-content {
  height: auto;
  min-height: 400px;
  padding: 80px 40px;
  background: #ffffff;
  border-radius: 24px;
  -webkit-box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  -webkit-transition: var(--transition);
  transition: var(--transition);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.intro-title {
  font-size: 2.8rem;
  margin-bottom: 20px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
  color: #1a1a2e;
}

.intro-description {
  font-size: 1.2rem;
  margin-bottom: 35px;
  color: #4a4a6a;
  font-weight: 400;
  line-height: 1.6;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.intro-buttons {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  padding: 40px 0 0;
  margin: -8px;
}

.intro-buttons .btn {
  margin: 8px;
}

.btn {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-transition: var(--transition);
  transition: var(--transition);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn i {
  margin-right: 8px;
  font-size: 1.1rem;
}

.btn-primary {
  background: #4361ee;
  color: white;
  border: 1px solid #4361ee;
  -webkit-box-shadow: 0 4px 12px rgba(67, 97, 238, 0.25);
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.25);
}

.btn-primary:hover {
  background: #3a56d4;
  -webkit-transform: translateY(-2px);
  transform: translateY(-2px);
  -webkit-box-shadow: 0 6px 16px rgba(67, 97, 238, 0.35);
  box-shadow: 0 6px 16px rgba(67, 97, 238, 0.35);
}

.btn-outline {
  background: transparent;
  color: #4361ee;
  border: 1px solid #4361ee;
}

.btn-outline:hover {
  background: #4361ee;
  color: white;
  -webkit-transform: translateY(-2px);
  transform: translateY(-2px);
  -webkit-box-shadow: 0 6px 16px rgba(67, 97, 238, 0.35);
  box-shadow: 0 6px 16px rgba(67, 97, 238, 0.35);
}

/* 辅助类 */
.text-gradient {
  background: -webkit-linear-gradient(90deg, #4361ee, #4895ef);
  background: linear-gradient(90deg, #4361ee, #4895ef);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% auto;
  -webkit-animation: gradientShift 3s ease infinite;
  animation: gradientShift 3s ease infinite;
}

@-webkit-keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 响应式设计 */
@media (max-width: 992px) {
  .intro-content {
    padding: 60px 30px;
  }
  
  .intro-title {
    font-size: 2.4rem;
  }
  
  .intro-description {
    font-size: 1.1rem;
  }
}

@media (max-width: 768px) {
  .platform-intro {
    padding: 60px 0 30px;
  }
  
  .intro-content {
    padding: 50px 20px;
    min-height: 300px;
  }
  
  .intro-title {
    font-size: 2rem;
    padding: 0 10px;
  }
  
  .intro-description {
    font-size: 1rem;
    padding: 0 10px;
    margin-bottom: 25px;
  }
  
  .intro-buttons {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    padding-top: 25px;
    margin: -6px;
    width: 100%;
    max-width: 280px;
  }
  
  .intro-buttons .btn {
    margin: 6px;
    width: 100%;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
  }
  
  .btn {
    width: 100%;
    max-width: 250px;
  }
}

@media (max-width: 480px) {
  .platform-intro {
    padding: 40px 0 20px;
  }
  
  .intro-content {
    padding: 40px 15px;
    min-height: 250px;
  }
  
  .intro-title {
    font-size: 1.8rem;
  }
  
  .intro-description {
    font-size: 0.95rem;
  }
  
  .btn {
    padding: 10px 20px;
    font-size: 0.95rem;
  }
  
  .btn i {
    font-size: 1rem;
  }
}

/* 额外的兼容性修复 */
.text-gradient {
  /* 为不支持 background-clip: text 的浏览器提供回退 */
  color: #4361ee;
}

/* 清除浮动 */
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

/* 按钮激活状态 */
.btn-active {
  -webkit-transform: scale(0.95);
  transform: scale(0.95);
  -webkit-box-shadow: 0 2px 8px rgba(67, 97, 238, 0.3);
  box-shadow: 0 2px 8px rgba(67, 97, 238, 0.3);
}
</style>